import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  OneToMany,
  JoinColumn,
  ManyToMany,
  JoinTable,
  OneToOne,
} from 'typeorm';
import { Logs } from './logs.entity';
import { Roles } from './roles.entity';
import { Profile } from './profile.entity';
@Entity()
export class User {
  constructor(
    id: number,
    username: string,
    password: string,
    email: string,
    gender: number,
    logs: Logs[],
    roles: Roles[],
    profile: Profile,
  ) {
    this.username = username;
    this.id = id;
    this.password = password;
    this.email = email;
    this.gender = gender;
    this.logs = logs;
    this.roles = roles;
    this.profile = profile;
  }
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  username: string;

  @Column()
  password: string;

  @Column()
  email: string;

  @Column()
  gender: number;

  @OneToMany(() => Logs, (logs) => logs.user)
  @JoinColumn()
  logs: Logs[];

  @ManyToMany(() => Roles, (roles) => roles.users)
  @JoinTable({ name: 'user_roles' })
  roles: Roles[];

  @OneToOne(() => Profile, (profile) => profile.user)
  profile: Profile;
}
